<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <link rel="stylesheet" type="text/css" href="../resources/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../resources/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="../resources/css/grumble.css">

    <script type="text/javascript" src="../resources/scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../resources/scripts/bootstrap.js"></script>
    <script type="text/javascript" src="../resources/scripts/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="../resources/scripts/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript" src="../resources/scripts/jquery.grumble.min.js"></script>
    <script type="text/javascript" src="../resources/scripts/zhBase.js"></script>
    <script type="text/javascript" src="../resources/scripts/zhForm.js"></script>
    <script charset="utf-8" src="../resources/scripts/kindeditor-4.1.1/kindeditor-min.js"></script>
    <script charset="utf-8" src="../resources/scripts/kindeditor-4.1.1/lang/zh_CN.js"></script>
    <script>
        $(function () {

            /**
             * 提交后的响应函数
             * @param data 服务器返回
             */
            function deal(data) {
                alert(data.msg);
            }

            var zf = new zhForm($("#formId"));
            $("#btnid").click(function () {
                var isSuccess = zf.verify();
                if (isSuccess) {
                    zf.submitForm(deal);
                }
            });
        });
    </script>
</head>
<BODY class="mian_bg">
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
    <TR height=28>
        <TD class="addr_td">&nbsp;&nbsp;<img src="/sys/resources/images/addr_icon.png">&nbsp;当前位置: 新闻管理>编辑新闻</TD>
    </TR>
    <TR>
        <TD bgColor=#7ca600 height=1></TD>
    </TR>
    <TR>
        <TD bgColor=#8ebe00 height=1></TD>
    </TR>
</TABLE>

<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">编辑新闻</h3>
        </div>
        <div class="panel-body">
            <form action="/sys/news/editData.do" id="formId" name="form" class="form-horizontal" role="form">
                <div class="row">
                    <div class="col-xs-8">
                        <div class="form-group">
                            <label for="title" class="col-sm-3 control-label">新闻名称</label>

                            <div class="col-sm-9">
                                <input type="hidden" name="id" value="${news.id}"/>
                                <input name="title" value="${news.title}" type="text" notNull="true" class="form-control" id="title"
                                       placeholder="新闻名称">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-8">
                        <div class="form-group">
                            <label for="title" class="col-sm-3 control-label">新闻类型</label>

                            <div class="col-sm-9">
                                <select class="form-control" name="type" notNull="true">

                                    <c:choose>
                                        <c:when test="${news.type==1}">
                                            <option value=""></option>
                                            <option value="1"  selected >新闻</option>
                                            <option value="2" >公告</option>
                                            <option value="3" >支部风采</option>
                                            <%--<option value="4" >党员事迹</option>--%>
                                            <%--<option value="5" >党建导读</option>--%>
                                        </c:when>
                                        <c:when test="${news.type==2}">
                                            <option value=""></option>
                                            <option value="1"  >新闻</option>
                                            <option value="2" selected >公告</option>
                                            <option value="3" >支部风采</option>
                                            <%--<option value="4" >党员事迹</option>--%>
                                            <%--<option value="5" >党建导读</option>--%>
                                        </c:when>
                                        <c:when test="${news.type==3}">
                                            <option value=""></option>
                                            <option value="1"  >新闻</option>
                                            <option value="2"  >公告</option>
                                            <option value="3" selected>支部风采</option>
                                            <%--<option value="4" >党员事迹</option>--%>
                                            <%--<option value="5" >党建导读</option>--%>
                                        </c:when>
                                        <%--<c:when test="${news.type==4}">--%>
                                            <%--<option value=""></option>--%>
                                            <%--<option value="1"  >新闻</option>--%>
                                            <%--<option value="2"  >公告</option>--%>
                                            <%--<option value="3" >支部风采</option>--%>
                                            <%--<option value="4" selected>党员事迹</option>--%>
                                            <%--&lt;%&ndash;<option value="5" >党建导读</option>&ndash;%&gt;--%>
                                        <%--</c:when>--%>
                                        <%--<c:when test="${news.type==5}">--%>
                                            <%--<option value=""></option>--%>
                                            <%--<option value="1"  >新闻</option>--%>
                                            <%--<option value="2"  >公告</option>--%>
                                            <%--<option value="3" >支部风采</option>--%>
                                            <%--<option value="4" >党员事迹</option>--%>
                                            <%--<option value="5" selected>党建导读</option>--%>
                                        <%--</c:when>--%>
                                        <c:otherwise>
                                            <option value="" selected></option>
                                            <option value="1"  >新闻</option>
                                            <option value="2"  >公告</option>
                                            <option value="3" >支部风采</option>
                                            <%--<option value="4" >党员事迹</option>--%>
                                            <%--<option value="5" >党建导读</option>--%>
                                        </c:otherwise>
                                    </c:choose>

                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-8">
                        <div class="form-group">
                            <label for="title" class="col-sm-3 control-label">新闻内容</label>
                            <div class="col-sm-9">
                                <textarea id="content" name="content" class="form-control" notNull="true" rows="25">${content}</textarea>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-2">
                    </div>
                    <div class="col-xs-4">
                        <button type="button" id="btnid" class="btn btn-success btn-block">提交</button>
                    </div>
                    <div class="col-xs-2">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            resizeType:0,
            allowPreviewEmoticons:false,
            allowUpload:true,
            //是否可以弹出对话框选择文件
            allowFileManager:true,
            //文件选择的时候弹出的对话框/对话框中可以放置服务器图片文件
            allowImageUpload:true,
            uploadJson:"/file/imageUpload.do",
            syncType:"absolute",
            items:['source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', '|', 'selectall','title', 'fontname', 'fontsize', '|', 'textcolor',
                'bgcolor', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|'
                , 'advtable', 'hr', 'emoticons',  'image', 'insertfile','link', 'unlink'],
            afterCreate:function () {
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    document.forms['form'].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    document.forms['form'].submit();
                });
            },
            afterBlur:function () {
                this.sync();
            }
        });
    });
</script>
</body>
</html>
